﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>操作</title>
    <script src="../../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
</head>
<body>
   
    <script type="text/javascript">

        $(function () {


       
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork");

            handler.AddUrlData();
            var data = handler.DoMethodReturnString("OP_GetStatus");

            data = JSON.parse(data);

            // var html = addFlowOverByCoercion(data.CanFlowOverByCoercion);

            var html = ""; // addFlowOverByCoercion(data.CanFlowOverByCoercion);

            //html += addTackBack(data.CanTackBack, data.TackBackFromNode, data.TackBackToNode);
            //html += addHurry(data.CanHurry);
            // html += addUnSend(data.CanUnSend);
            //html += addRollBack(data.CanRollBack);
            //html += addUnHungUp(data.CanUnHungUp);

            html += addPackUp(data.CanPackUp);

            $("#ccop").append(html);

        });

        //删除流程
        function addFlowOverByCoercion(isCan) {

            if (typeof isCan == "undefined") {
                return "";
            }

            var html = addBlockBegin("删除流程");

            if (isCan) {
                html += "功能执行:<a href=\"javascript:DeleteFlowInstance('" + GetQueryString("fk_flow") + "','" + GetQueryString("WorkID") + "')\" >点击执行删除流程</a>。";
                html += "<br />说明：如果执行流程将会被彻底的删除。";
            }
            else {
                html += "您没有删除该流程的权限。";
            }

            html += addBlockEnd();

            return html;
        }

        //取回审批
        function addTackBack(isCan, fromNode, toNode) {
            if (typeof isCan == "undefined") {
                return "";
            }

            var html = addBlockBegin("取回审批");

            if (isCan) {
                html += "功能执行:<a href=\"javascript:Takeback('" + workid + "','" + fk_flow + "','" + fromNode + "','" + toNode + "')\" >点击执行取回审批流程</a>。";
                html += "<br />说明：如果被成功取回，ccflow就会把停留在别人工作节点上的工作发送到您的待办列表里。";
            }
            else {
                html += "您没有此权限。";
            }

            html += addBlockEnd();

            return html;
        }

        //催办
        function addHurry(isCan) {
            if (typeof isCan == "undefined") {
                return "";
            }

            var html = addBlockBegin("工作催办");
            html += "您没有此权限。";
            html += addBlockEnd();

            return html;
        }

        //撤销发送
        function addUnSend(isCan) {
            if (typeof isCan == "undefined") {
                return "";
            }

            var html = addBlockBegin("撤销发送");

            if (isCan) {
                html += "功能执行:<a href =\"javascript:UnSend('" + fk_flow + "','" + workid + "','" + fid + "')\" >撤销发送</a>。";
            }
            else {
                html += "您没有此权限。";
            }

            html += addBlockEnd();

            return html;
        }

        //恢复使用流程
        function addRollBack(isCan) {
            if (typeof isCan == "undefined") {
                return "";
            }

            var html = addBlockBegin("恢复启用流程数据到结束节点");

            if (isCan) {
                html += "功能执行:<a href=\"javascript:DoFunc('OP_ComeBack','" + workid + "','" + fk_flow + "','" + fk_node + "')\" >点击执行恢复流程</a>。";
                html += "<br />说明：如果被成功恢复，ccflow就会把待办工作发送给最后一个结束流程的工作人员。";
            }
            else {
                html += "您没有此权限。";
            }

            html += addBlockEnd();

            return html;
        }


        //撤销挂起
        function addUnHungUp(isCan) {
            if (typeof isCan == "undefined") {
                return "";
            }

            var html = addBlockBegin("取消挂起");

            if (isCan) {
                html += "功能执行:<a href=\"javascript:DoFunc('OP_UnHungUp','" + workid + "','" + fk_flow + "','" + fk_node + "')\" >点击执行取消挂起流程</a>。";
                html += "<br />说明：解除流程挂起的状态。";
            }
            else {
                html += "您没有此权限，或者当前不是挂起的状态。";
            }

            html += addBlockEnd();

            return html;
        }

        ///增加打印.
        function addPackUp(isCan) {

            if (typeof isCan == "undefined") {
                return "";
            }

            if (isCan == false || isCan == "false")
                return "";

            var fk_node = GetQueryString("FK_Node");
            if (fk_node == null)
                  fk_node = GetQueryString("NodeID");

            var html = addBlockBegin("打印/打包下载");

            if (isCan) {
                html += "功能执行:<a href='../Packup.htm?FileType=zip,pdf&WorkID=" + GetQueryString("WorkID") + "&FK_Flow=" + GetQueryString("FK_Flow") + "&NodeID=" + GetQueryString("FK_Node") + "&FK_Node=" + GetQueryString("FK_Node") + "' >执行打印</a>。";
                html += "<br />说明：把表单输出到html,pdf,zip文件里，执行下载或打印.";
            }
            else {
                html += "您没有此权限。";
            }

            html += addBlockEnd();

            return html;
        }
        

        //删除流程.
        function DeleteFlowInstance(flowNo, workid) {
            var url = '../DeleteFlowInstance.htm?FK_Flow=' + flowNo + '&WorkID=' + workid;
            WinOpen(url);
        }

        function DoFunc(doType, workid, fk_flow, fk_node) {
            if (doType == 'OP_DelFlow' || doType == 'Reset') {
                if (confirm('您确定要执行吗？') == false)
                    return;
            }

            var url = '';

            if (doType == 'OP_HungUp' || doType == 'OP_UnHungUp') {
                url = './../HungUpOp.aspx?WorkID=' + workid + '&FK_Flow=' + fk_flow + '&FK_Node=' + fk_node;
                var str = window.showModalDialog(url, '', 'dialogHeight: 350px; dialogWidth:500px;center: no; help: no');
                if (str == undefined)
                    return;
                if (str == null)
                    return;

                window.location.href = window.location.href;
                return;
            }

            url = Handler + '?DoType=' + doType + '&WorkID=' + workid + '&FK_Flow=' + fk_flow + '&FK_Node=' + fk_node;
            $.post(url, null, function (msg) {
                $("#opmsg").empty().append(msg);
            });
        }

        function Takeback(workid, fk_flow, fk_node, toNode) {
            if (confirm('您确定要执行吗？') == false)
                return;
            var url = '../../GetTask.aspx?DoType=Tackback&FK_Flow=' + fk_flow + '&FK_Node=' + fk_node + '&ToNode=' + toNode + '&WorkID=' + workid;
            window.location.href = url;
        }

        function UnSend(fk_flow, workID, fid) {
            if (confirm('您确定要执行撤销吗?') == false)
                return;

            var url = Handler + "?DoType=OP_UnSend&FK_Node=<%=FK_Node %>&FK_Flow=" + fk_flow + "&WorkID=" + workID;
            $.post(url, null, function (msg) {
                $("#opmsg").empty().append(msg);
            });
        }

        function addBlockBegin(title) {
            var html = "<table class='Table' cellspacing='0' cellpadding='0' border='0' style='width:100%;margin-bottom:5px;'>";
            html += "<tr><td class='GroupTitle'>" + title + "</td></tr>";
            html += "<tr><td style='padding:10px'>";
            return html;
        }

        function addBlockEnd() {
            return "</td></tr></table>";
        }
    </script>
    <div id="ccop" style="width: 100%; height: auto">
    </div>
    <div id="opmsg" style="width: 100%; height: auto">
    </div>
</body>
</html>
